package com.ymttest.utils.compare.parameter;

import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ymttest.utils.JsonBeanHelper;
import com.ymttest.utils.compare.AssertHelper;
import com.ymttest.utils.compare.LogPathConf;
import com.ymttest.utils.compare.LoggerHelper;
import com.ymttest.utils.compare.LoggerInterface;

public class MainTest {

	
	
	public static void main(String[] args) throws Exception {
		LogPathConf logPathConf = new LogPathConf(false);
		LoggerInterface logger = new LoggerHelper(logPathConf);
		AssertHelper.setLoggerInterface(logger);
		
		
		JSONObject a1 = JsonBeanHelper.getJsonBean("tmp\\a1.json");
		TestParentBean a1Bean1 = getBeanFromJson(a1,TestParentBean.class);
		
		
		JSONObject a2 = JsonBeanHelper.getJsonBean("tmp\\a2.json");
		TestParentBean a2Bean2 = getBeanFromJson(a2,TestParentBean.class);	
		
		
		AssertHelper.assertResultEqual(a1Bean1, a2Bean2, "testcompare");
		System.out.println("Ok");
	
	}
	
	public static <T> T getBeanFromJson(JSONObject jsonObject, Class<T> clz){
		Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss").create();
		return  gson.fromJson(jsonObject.toString(), clz);
	}
	
	
}
